package com.scaffold.card.action;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import wangjg.commons.page.Page;

import com.scaffold.BasicBizAction;
import com.scaffold.card.entity.Category;
import com.scaffold.card.entity.SimpleCard;
import com.scaffold.card.service.CategoryService;
import com.scaffold.card.service.SimpleCardService;

/**
 * 目录操作接口(json)
 * @author wangjg
 */
@Controller
public class MobileJsonAction extends BasicBizAction{
	@Autowired
	private CategoryService categoryService;
	@Autowired
	private SimpleCardService simpleCardService;
	
	@RequestMapping("/mobile/category/list.json")
	public String list(String keyword){
		Page page = this.getPage(20);
		List<Category> list = categoryService.queryValidList(page);
		return this.getPageResult(page, list);
	}
	
	@RequestMapping("/mobile/card/list.json")
	public String list(Long categoryId){
		List<SimpleCard> list = simpleCardService.queryValidList(categoryId);
		return this.getSuccessResult(list);
	}

	
	int ________wap_______;
	
	/**
	 * 目录列表
	 * @param keyword 查询关键字
	 */
	@RequestMapping("/mobile/wap/category/list.xhtml")
	public String list(ModelMap model, Integer sortNo, String name, String photo, String enabled, String keyword){
		Page page = this.getPage(20);
		List<Category> list = categoryService.pageQuery(page, keyword, enabled);
		model.put("categoryList", list);
		model.put("page", page);

		return "/category/categoryList.vm";
	}
	
}
